package com.example.canteen;

import com.example.canteen.controller.UserController;
import com.example.canteen.domain.User;
import com.example.canteen.util.AjaxResult;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class testUserController {
    @Autowired
    private UserController userController;
    @Test
    public void testGetUserById(){
        AjaxResult result1=userController.getUserById(2);
        Assertions.assertTrue(result1.isSuccess());
        User user=(User)result1.get("Data");
        Assertions.assertEquals(user.getUserid(),1);
    }
    @Test
    public void testDeleteUser(){
        AjaxResult result2=userController.DeleteUser(2);
        Assertions.assertTrue(result2.isSuccess());
        int deleteDates=(int)result2.get("data");
        Assertions.assertEquals(deleteDates,1);
        AjaxResult result1=userController.DeleteUser(999);
        int deleteDates1 = (int)result1.get("data");
    }

}
